<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>财务报表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<jsp:include page="${pageContext.request.contextPath }/resource_path.jsp" flush="true"/>
</head>
<body class="layui-anim layui-anim-up">
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a>
          <cite>财务报表</cite>
        </a>
      </span>
    </div>
    <div class="x-body">
      <div style="margin-bottom: 18px">
		<div class="layui-inline">
			<table>
				<tr>
					<td>
						<div class="layui-input-block" style="width:200px;margin-left: 0px;margin-top: 0px;">
							<select class="layui-input" name="keyword02" id="keyword02">
								<option value="dd">日报表</option>
								<option value="week">周报表</option>
								<option value="month">月报表</option>
								<option value="quarter">季报表</option>
								<option value="year">年报表</option>
							</select>
						</div>
					</td>
					<td>
						<input class="layui-input" id="create_date" placeholder="请输入日期" autocomplete="off" style="display: inline; width: 180px;">
					</td>
					<td>
						<input type="hidden" id="clientId" name="clientId" value="${customer_id}">
						<div class="layui-input-block" style="width:200px;margin-left: 0px;margin-top: 0px;">
							<select class="layui-input" name="keyword01" id="keyword01">
								<option value="">请选择项目</option>
								<c:forEach items="${items}" var="item">
									<option value="${item.id}">${item.itemName}-${item.itemNumber}</option>
								</c:forEach>
							</select>
						</div>
					</td>
					
				</tr>
			</table>
		</div>
		<button class="layui-btn layui-btn-normal" data-type="reload"><i class="layui-icon">&#xe615;</i>检索</button>
	  </div>
	  <table class="layui-hide" id="tableList" lay-filter="tableList"></table>
	</div>
	<script src="${pageContext.request.contextPath }/js/td/layuiRowspan.js" charset="utf-8"></script>
	<script type="text/javascript">
        var table;
		layui.use(['table','layer','upload','form','laydate'], function(){
			table = layui.table;
			var layer = layui.layer;
			var form = layui.form;
			var laydate = layui.laydate;
			//执行一个laydate实例
			laydate.render({
				elem: '#create_date', //指定元素
				type: 'date',
				value: new Date(),
				format: 'yyyy-MM-dd', //自动生成的时间格式   
				btns: ['now', 'confirm']
			});
			var $ = layui.jquery, active = {
				reload:function () {
					var keyword01 = $.trim($("#keyword01").val());
	                var keyword02 = $.trim($("#keyword02").val());
	                var create_date = $.trim($("#create_date").val());
					table.reload('tableList',{
						method:'get'
						,where:{
							id:keyword01
	                        ,type:keyword02
	                        ,create_date:create_date
						}
						,page: {
		                    curr: 1//重新从第 1 页开始
		                }
					});
				}
			}
			$('.layui-btn').on('click', function(){
				var type = $(this).data('type');
				active[type] ? active[type].call(this) : '';
			});
			var clientId = $.trim($("#clientId").val());
			var keyword01 = $.trim($("#keyword01").val());
            var keyword02 = $.trim($("#keyword02").val());
            $("#create_date").val(curentDate())
            var create_date = $.trim($("#create_date").val());
			var url = '${pageContext.request.contextPath }/reconciliation/financeList.do'
				url += '?client_id='+clientId
			table.render({
				elem: '#tableList'
				,where:{
					id:keyword01
                    ,type:keyword02
                    ,create_date:create_date
				}
				,url:url
				,toolbar: '#toolbar'
				,title: 'machineList'
				,limits:[10,20,30]
                ,defaultToolbar:['filter', 'print']
				,request: {   //如果无需自定义请求参数，可不加该参数
	                pageName: 'page' //页码的参数名称，默认：page
	                ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
	            }
	            ,response: {   //如果无需自定义数据响应名称，可不加该参数
	                countName: 'total' //规定数据总数的字段名称，默认：count
	                ,dataName: 'rows' //规定数据列表的字段名称，默认：data
	            }
				,cols: [
		                [{
		                    type: 'checkbox',
		                    fixed: 'left'
		                }, {
		                	field:'id',
		                	title:'序号', 
		                	sort: true,
		                	width: 60,
		                	type:'numbers',
		                	align:'center'
		                }, {
		                    field: 'id',
		                    title: 'id',
		                    hide:true //是否初始隐藏列，默认：false。layui 2.4.0 新增
		                } , {
		                    field: 'item_name',
		                    title: '项目名称',
		                    align:'center',
		                } , {
		                    field: 'item_number',
		                    title: '项目编号',
		                    align:'center',
		                } , {
		                    field: 'explain',
		                    title: '项目说明',
		                    align:'center',
		                } , {
		                    field: 'yfmoney',
		                    title: '应付金额',
		                    align:'center',
		                } , {
		                    field: 'yfbqinvoiceMoney',
		                    title: '本期发票金额',
		                    align:'center',
		                } , {
		                    field: 'yfinvoice',
		                    title: '发票金额',
		                    align:'center',
		                } , {
		                    field: 'ysmoney',
		                    title: '应收金额',
		                    align:'center',
		                } , {
		                    field: 'ysbqinvoiceMoney',
		                    title: '本期开票金额',
		                    align:'center',
		                } , {
		                    field: 'ysbqtaxMoney',
		                    title: '本期开票税金',
		                    align:'center',
		                } , {
		                    title: '本期税后金额',
		                    align:'center',
		                    templet: function(d){
		                    	var value = d.ysbqinvoiceMoney - d.ysbqtaxMoney;
            	    			return value;
            	    		} 
		                } , {
		                    field: 'ysinvoice',
		                    title: '开票金额',
		                    align:'center',
		                } , {
		                    field: 'ystax',
		                    title: '开票税金',
		                    align:'center',
		                } , {
		                    title: '税后金额',
		                    align:'center',
		                    templet: function(d){
		                    	var value = d.ysinvoice - d.ystax;
            	    			return value;
            	    		} 
		                }
		                ]
		               ]
				,page: true
				,done : function(){
	                $('th').css({
	                    'background-color': '#009688', 'color': '#fff','font-weight':'bold',
	                    //'font-size': 10,
	                })
	                layuiRowspan(['customer_name'], 1);//支持数组
	            }
			});
		});
		//获取当前日期
	   	function curentDate() {
	   		var now=new Date();
	   		var year = now.getFullYear();       //年
	   	    var month = now.getMonth() + 1;     //月
	   	    var day = now.getDate();            //日
	   	    var time=year+"-"+add0(month)+"-"+add0(day);
	   		return time;
	   	}
	   	function add0(m){return m<10?'0'+m:m }
		toastrStyle()
	</script>
</body>
</html>